#ifndef TEST_FUNCTIONS_H_INCLUDED
#define TEST_FUNCTIONS_H_INCLUDED

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <windows.h>
#include <Shlwapi.h>
#include <limits.h>

#include "HeapAllocator.h"

const char characterArray[10]= {'0','1','2','3','4','5','6','7','8','9'};

void
runUnitTests(void);

void gotoXY(int x, int y);

void drawPageMap(int maxWidth, TRACKING_UNIT* pages, U32 length);

void drawPointerList(int xOffset, int yOffset, std::vector<void*> pointers, CEngine::HeapAllocator* heap);

U32 getDigits(U32 number);

void radixSort(U32 list[], const U32 arraySize, const U32 length, U32& count);

void top(const U32 size, std::fstream& file);

void middle(const U32 size, std::fstream& file);

void bottom(const U32 size, std::fstream& file);

U64 hashString(const char* string);

template<class INT>
INT stringToUnsigned(char* string);

template<class INT>
char* unsignedToString(const INT number);

template<class INT>
INT stringToUnsigned(char* string) {
    INT temp = 0;

    int length = 0;
    for (int i = 0; string[i] != '\0' ; ++i) {
        ++length;
    }

    for (int i = 0; i < length; ++i) {
        INT decimal = 0;
        for (int c = 0; c < 10; ++c) {
            if (string[length - (i + 1)] == characterArray[c]) {
                decimal = c;
                break;
            }
        }
        for (int c = 0; c < i; ++c) {
            decimal *= 10;
        }
        temp += decimal;
    }
    return temp;
}

template<class INT>
char* unsignedToString(const INT number) {
    char buffer[39];
    INT temp = number;
    int length = 0;
    char* stringPointer;

    if (number == 0) {
        stringPointer = new char[2];
        stringPointer[0] = '0';
        stringPointer[1] = '\0';
        return stringPointer;
    }

    while (temp > 0) {
        int decimal = temp % 10;
        buffer[39 - (length + 1)] = characterArray[decimal];
        temp = temp / 10;
        ++length;
    }

    stringPointer = new char[length + 1];

    for (int i = 0; i < length; ++i) {
        stringPointer[i] = buffer[(39 - length) + i];
    }
    stringPointer[length] = '\0';

    return stringPointer;
}

class Test {
    public:

        Test(void);

        U32 value1;
};

#endif // TEST_FUNCTIONS_H_INCLUDED
